package com.clothing.customization.controller;

import com.clothing.customization.dto.ApiResult;
import com.clothing.customization.entity.ClothingAccessory;
import com.clothing.customization.entity.ClothingMaterial;
import com.clothing.customization.entity.ClothingStyle;
import com.clothing.customization.service.ClothingService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 服装相关控制器
 */
@RestController
@RequestMapping("/api/clothing")
@RequiredArgsConstructor
public class ClothingController {
    
    private final ClothingService clothingService;
    
    /**
     * 获取服装款式列表
     * @param params 查询参数
     * @return 款式列表
     */
    @GetMapping("/styles")
    public ResponseEntity<ApiResult<List<ClothingStyle>>> getStyles(@RequestParam Map<String, Object> params) {
        List<ClothingStyle> styles = clothingService.getStyles(params);
        return ResponseEntity.ok(ApiResult.success(styles));
    }
    
    /**
     * 获取服装材质列表
     * @param params 查询参数
     * @return 材质列表
     */
    @GetMapping("/materials")
    public ResponseEntity<ApiResult<List<ClothingMaterial>>> getMaterials(@RequestParam Map<String, Object> params) {
        List<ClothingMaterial> materials = clothingService.getMaterials(params);
        return ResponseEntity.ok(ApiResult.success(materials));
    }
    
    /**
     * 获取服装配饰列表
     * @param params 查询参数
     * @return 配饰列表
     */
    @GetMapping("/accessories")
    public ResponseEntity<ApiResult<List<ClothingAccessory>>> getAccessories(@RequestParam Map<String, Object> params) {
        List<ClothingAccessory> accessories = clothingService.getAccessories(params);
        return ResponseEntity.ok(ApiResult.success(accessories));
    }
    
    /**
     * 获取服装款式详情
     * @param id 款式ID
     * @return 款式详情
     */
    @GetMapping("/styles/{id}")
    public ResponseEntity<ApiResult<ClothingStyle>> getStyleDetail(@PathVariable Long id) {
        ClothingStyle style = clothingService.getStyleById(id);
        return ResponseEntity.ok(ApiResult.success(style));
    }
    
    /**
     * 获取服装材质详情
     * @param id 材质ID
     * @return 材质详情
     */
    @GetMapping("/materials/{id}")
    public ResponseEntity<ApiResult<ClothingMaterial>> getMaterialDetail(@PathVariable Long id) {
        ClothingMaterial material = clothingService.getMaterialById(id);
        return ResponseEntity.ok(ApiResult.success(material));
    }
    
    /**
     * 获取服装配饰详情
     * @param id 配饰ID
     * @return 配饰详情
     */
    @GetMapping("/accessories/{id}")
    public ResponseEntity<ApiResult<ClothingAccessory>> getAccessoryDetail(@PathVariable Long id) {
        ClothingAccessory accessory = clothingService.getAccessoryById(id);
        return ResponseEntity.ok(ApiResult.success(accessory));
    }
} 